# -*- coding: utf-8 -*-
# @Time    : 2024/2/20 22:14
# @Author  : micah
# @File    : 25.pyppeteer框架的基本使用.py
# @Software: PyCharm


# pip install pyppeteer==1.0.2

import asyncio
from pyppeteer import launch


async def main():
    browser = await launch()  # 无头模式
    page = await browser.newPage()
    await page.goto('https://www.baidu.com')
    await page.screenshot({'path': 'baidu.png'})  # 截图并保存
    await page.close()


asyncio.get_event_loop().run_until_complete(main())
